<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta property="qc:admins" content="6525276424516367" />
    <meta property="wb:webmaster" content="ce8327d47982a584" />

    <title>慕图素材</title>

    <link rel="stylesheet" href="/static/lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/static/schema/default/css/base.css">
    <link href="/static/schema/default/css/dashboard.css" rel="stylesheet">
    <script src="/static/lib/jquery/jquery-2.1.3.min.js"></script>

   
</head>
<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div id="navbar" class="navbar-collapse collapse row">
                <div class="col-sm-offset-1">
                    <ul class="nav navbar-nav">
                        <li >
                            <a href="/">首页</a>
                        </li>
                        <li >
                            <a href="/auth/index">登录</a>
                        </li>
                        <li >
                            <a href="/auth/logout">退出</a>
                        </li>
                        <li >
                            <a href="/resource/upload/index">上传资源</a>
                        </li>
                        <li >
                            <a href="/resource/matter/create/index">创建素材</a>
                        </li>
                        <li >
                            <a href="/resource/matter/manage/index">素材管理</a>
                        </li>
                       
                        <li >
                            <a href="/resource/binder/manage/index">收藏夹管理</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-2 alertDiv" id="notice_messages"></div>
        </div>
    </div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-10 col-sm-offset-1 main">
                <form action="" method="post" id="matterForm" class="form-horizontal" for="ala_ocr"enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="flag">公开：</label>
                            <div class="controls col-sm-4">
                                <label class="radio-inline">
                                    <input type="radio" name="ispub" value="1" checked="checked">是</label>
                                <label class="radio-inline">
                                    <input type="radio" name="ispub" value="0">否</label>
                                
                                
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="cats">分类：</label>
                            <div class="controls col-sm-7">
                                {{ range .cats }}
                                <label>
                                    <input type="radio" name="cats" value="{{ .Id }}">  
                                        {{ .Name }} 
                                 </label>
                                 {{ end }}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="tags">标签：</label>
                            <div class="controls col-sm-7">
                                {{ range .tags }}
                                <label>
                                    <input type="checkbox" name="tags" value="{{ .Id }}">  
                                        {{ .Name }} 
                                 </label>
                                 {{ end }}
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="title">标题：</label>
                            <div class="controls col-sm-4">
                                <input class="form-control" name="title" type="text" value=""></div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="desc">描述：</label>
                            <div class="controls col-sm-4">
                            <textarea name="desc" class="form-control" rows="10"></textarea>    
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1" for="address"></label>
                            <button class="btn btn-primary" onclick="create()" type="button">创建</button>
                        </div>

                    </form>
                </div>

            </div>
        </div>
    </div>


<script type="text/javascript">
   

    function create(){
        var ispub = $("#matterForm [name='ispub']:checked").val();
        var cat = $("#matterForm [name='cats']:checked").val();
        var tags = "";
        $("#matterForm [name='tags']:checked").each(function(){
            tags += $(this).val() + ",";
        });

        var title = $("#matterForm [name='title']").val();
        var desc = $("#matterForm textarea[name='desc']").val();
        
        var data = {
            "ispub": ispub,
            "categroy": cat,
            "tags": tags,
            "title": title,
            "desc": desc,
        }
        var url = "/resource/binder/create";
        $.post(url, data, function(body){
            res = body;
            if (res.ok) {
                alert("创建成功");
            }else {
                alert(res.msg);
            }
        });
        /*
        $.ajax({
            type: 'POST',
            url: url,
            data: data,
            dataType: txt,
            success: function(body){
                alert(body);
            },
            error: function(e ){
                alert("ajax网络错误，" + e);
            },
            dataType: dataType
        });
        */
        
    }
</script>

</body>
</html>
